﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace nextwaver.SelfLearning
{
    public class GridViewUtils
    {
        #region Field 
        private ArrayList parameter;
        private ArrayList parameterList = new ArrayList();
        #endregion

        private ArrayList ParameterList
        {
            get { return parameterList; }
        }

        public void SetParameterColumn(string FieldName, string valueDisplay, bool columnDisplay)
        {
            parameter = new ArrayList();

            parameter.Add(FieldName);
            parameter.Add(valueDisplay);
            parameter.Add(columnDisplay);

            ParameterList.Add(parameter);
        }

        public void GridViewRanderConfig(System.Windows.Forms.DataGridView gridView)
        {
            try
            {
                for (int l = 0; l < ParameterList.Count; l++)
                {
                    try
                    {
                        ArrayList parameter = (ArrayList)ParameterList[l];
                        string colOld = (string)parameter[0];
                        string colNew = (string)parameter[1];
                        bool visible = (bool)parameter[2];
                        gridView.Columns[colOld].DisplayIndex = l;
                        gridView.Columns[colOld].HeaderText = colNew;
                        gridView.Columns[colOld].Visible = visible;
                    }
                    catch { }
                }
            }
            catch { }
        }
    }
}